package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: sky-take-out
 * @description:
 * @author: 酷炫焦少
 * @create: 2024-11-17 15:03
 **/
@Api(tags = "菜品相关接口")
@RestController("adminSetmealController")
@RequestMapping("/admin/setmeal")
public class SetmealController {

    @Resource
    private SetmealService setmealService;

    @PostMapping
    @ApiOperation("新增套餐")
    public Result<String> addSetmeal(@RequestBody SetmealDTO setmealDTO) {
        return setmealService.addSetmeal(setmealDTO);
    }

    @GetMapping("/page")
    @ApiOperation("查询套餐列表")
    public Result<PageResult> page(SetmealPageQueryDTO setmealPageQueryDTO) {
        return setmealService.page(setmealPageQueryDTO);
    }

    @PostMapping("/status/{status}")
    @ApiOperation("修改套餐状态")
    public Result<String> editStatus(@PathVariable("status") Integer status, Long id) {
        return setmealService.editStatus(status, id);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询某一套餐")
    public Result<SetmealVO> getSetmealById(@PathVariable("id") Long id) {
        return setmealService.getSetmealById(id);
    }

    @PutMapping
    @ApiOperation("更改套餐")
    public Result<String> editSetmeal(@RequestBody SetmealDTO setmealDTO) {
        return setmealService.editSetmeal(setmealDTO);
    }

    @DeleteMapping
    @ApiOperation("删除套餐")
    public Result<String> deleteSetmeal(@RequestParam("ids") List<Long> ids) {
        return setmealService.deleteSetmeal(ids);
    }

}
